<?php
if (getenv("HTTP_X_FORWARDED_FOR")){
	$ip = getenv("HTTP_X_FORWARDED_FOR");
	$client = gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']);
  } else {
	$ip = getenv("REMOTE_ADDR");
	$client = gethostbyaddr($_SERVER['REMOTE_ADDR']);
   }
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ){ 
        $postText = file_get_contents('php://input'); 
}


$datetime=date('ymdHis'); 
$xmlfile = "../private/stats/develenv/" . "myfile" . $datetime . ".log"; 
$FileHandle = fopen($xmlfile, 'w') or die("can't open file"); 
fwrite($FileHandle, $postText);
fwrite($FileHandle, $ip);
fwrite($FileHandle, "\n" . $client); 
fclose($FileHandle);
$sys = exec ("../private/stats/process.sh ".$xmlfile);
echo "$sys";

?>
